<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="WHIT">
<span class='line'>  2</span> </span><span class="COMM">/**
<span class='line'>  3</span>  * @fileoverview Simple hoop chart implementation.
<span class='line'>  4</span>  * @version 1.0.1
<span class='line'>  5</span>  * @link http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
<span class='line'>  6</span>  * @link https://developers.google.com/closure/compiler/docs/js-for-compiler
<span class='line'>  7</span>  */</span><span class="WHIT">
<span class='line'>  8</span> 
<span class='line'>  9</span> 
<span class='line'> 10</span> 
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span>  * HoopChart constructor.
<span class='line'> 13</span>  * @param {string|Element} container The HTML container.
<span class='line'> 14</span>  * @constructor
<span class='line'> 15</span>  * @extends {charts.DonutChart} charts.DonutChart
<span class='line'> 16</span>  * @example
<span class='line'> 17</span>  * &lt;b>var&lt;/b> chart = &lt;b>new&lt;/b> charts.HoopChart('container_id');
<span class='line'> 18</span>  * chart.draw([['Work', 'Eat', 'Commute', 'Watch TV', 'Sleep'],
<span class='line'> 19</span>  *             [100, 50, 30, 10, 40], [140, 2, 110, 150, 1300]]);
<span class='line'> 20</span>  *
<span class='line'> 21</span>  * &lt;div style="border: solid 1px #ccc; margin: 5px; padding: 5px; width: 560px">
<span class='line'> 22</span>  *   &lt;div id="chart-container"
<span class='line'> 23</span>  *        style="width: 560px; height: 300px;">&lt;/div>
<span class='line'> 24</span>  * &lt;/div>
<span class='line'> 25</span>  * &lt;script src="../../bin/jscb.js">&lt;/script>
<span class='line'> 26</span>  * &lt;script>
<span class='line'> 27</span>  *   var chart = new charts.HoopChart('chart-container');
<span class='line'> 28</span>  *   chart.draw([['Work', 'Eat', 'Commute', 'Watch TV', 'Sleep'],
<span class='line'> 29</span>  *               [100, 50, 30, 10, 40], [140, 2, 110, 150, 1300]]);
<span class='line'> 30</span>  * &lt;/script>
<span class='line'> 31</span>  */</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="NAME">charts.HoopChart</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">container</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">  </span><span class="NAME">charts.DonutChart.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 36</span>    * Saved reference to charts.DonutChart.draw method.
<span class='line'> 37</span>    * @type {!function(!Array.&lt;Array>, Object=)}
<span class='line'> 38</span>    * @private
<span class='line'> 39</span>    */</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">draw_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.draw</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> 
<span class='line'> 42</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 43</span>    * Draws the chart based on &lt;code>data&lt;/code> and &lt;code>opt_options&lt;/code>.
<span class='line'> 44</span>    * @param {!Array.&lt;Array>} data A chart data.
<span class='line'> 45</span>    * @param {Object=} opt_options A optional chart's configuration options.
<span class='line'> 46</span>    * @see charts.DonutChart#draw
<span class='line'> 47</span>    * @see charts.PieChart#draw
<span class='line'> 48</span>    * @see charts.BaseChart#getOptions
<span class='line'> 49</span>    * @override
<span class='line'> 50</span>    * @example
<span class='line'> 51</span>    * options: {
<span class='line'> 52</span>    *   'hoop': {'radius': 0.85}
<span class='line'> 53</span>    *   'animation': {'radius': 1}
<span class='line'> 54</span>    * }
<span class='line'> 55</span>    */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">  </span><span class="NAME">this.draw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">    </span><span class="NAME">options_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getOptions_</span><span class="PUNC">(</span><span class="NAME">opt_options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">    </span><span class="NAME">draw_</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> 
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="COMM">// The timeout is waitings for charts.PieChart event initialization.</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">      </span><span class="COMM">/** @type {string} */</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tagName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charts.IS_SVG_SUPPORTED</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'text'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'textbox'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">      </span><span class="COMM">/** @type {NodeList} */</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">nodes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dom.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">self_.container</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tagName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="COMM">/** @type {number} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nodes.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">--</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">        </span><span class="NAME">nodes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">parentNode.removeChild</span><span class="PUNC">(</span><span class="NAME">nodes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> 
<span class='line'> 72</span> </span><span class="WHIT">  </span><span class="COMM">// Export for closure compiler.</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">  </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="STRN">'draw'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.draw</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> 
<span class='line'> 75</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 76</span>    * Gets circle area content.
<span class='line'> 77</span>    * @return {string} Returns circle area content.
<span class='line'> 78</span>    * @protected
<span class='line'> 79</span>    * @override
<span class='line'> 80</span>    * @expose
<span class='line'> 81</span>    */</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">  </span><span class="NAME">this.getAreaContent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">    </span><span class="COMM">// The @expose annotation fixes closure compiler multi-inheritance bug.</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {string} */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;div style="color:#aaa;font-size:15px">Example of&lt;/div>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">                  </span><span class="STRN">'&lt;div style="color:#666;font-size:18px">&lt;b>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">                  </span><span class="STRN">'HoopChart'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/b>&lt;/div>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">content</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> 
<span class='line'> 91</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 92</span>    * Gets chart's options merged with defaults chart's options.
<span class='line'> 93</span>    * @param {Object=} opt_options A optional chart's configuration options.
<span class='line'> 94</span>    * @return {!Object.&lt;string, *>} A map of name/value pairs.
<span class='line'> 95</span>    * @see charts.BaseChart#getOptions
<span class='line'> 96</span>    * @private
<span class='line'> 97</span>    * @example
<span class='line'> 98</span>    * options: {
<span class='line'> 99</span>    *   'hoop': {'radius': 0.85}
<span class='line'>100</span>    *   'animation': {'radius': 1}
<span class='line'>101</span>    * }
<span class='line'>102</span>    */</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getOptions_</span><span class="PUNC">(</span><span class="NAME">opt_options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'hoop'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'hoop'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'donut'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'donut'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'donut'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'radius'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'hoop'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'radius'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0.85</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'animation'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'animation'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'animation'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'radius'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">        </span><span class="NAME">opt_options</span><span class="PUNC">[</span><span class="STRN">'animation'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'radius'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">self_.getOptions</span><span class="PUNC">(</span><span class="NAME">opt_options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>113</span> 
<span class='line'>114</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>115</span>    * The reference to current class instance. Used in private methods.
<span class='line'>116</span>    * @type {!charts.HoopChart}
<span class='line'>117</span>    * @private
<span class='line'>118</span>    */</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> 
<span class='line'>121</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>122</span>    * @dict
<span class='line'>123</span>    * @private
<span class='line'>124</span>    */</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">options_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> 
<span class='line'>128</span> </span><span class="COMM">// Export for closure compiler.</span><span class="WHIT">
<span class='line'>129</span> </span><span class="NAME">charts</span><span class="PUNC">[</span><span class="STRN">'HoopChart'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charts.HoopChart</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> </span></pre></body></html>